package Feb_15;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class TcpClient {
    public static void main(String[] args) {
        try {
            InetAddress inetAddress = InetAddress.getByName("localhost");
            Socket socket = new Socket(inetAddress,5898);
            OutputStream outputStream =socket.getOutputStream();
            outputStream.write("wow".getBytes());
            outputStream.flush();

            byte[] bytes=new byte[512];
            InputStream inputStream=socket.getInputStream();
            inputStream.read(bytes);
            String str = new String(bytes);
            System.out.println(str);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}